﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace JustTypeUI.Data
{
    /// <summary>
    /// Provides logging to local log file
    /// 
    /// Main Author: Han Yu
    /// </summary>
    public class Log
    {
        public static void log(String message)
        {
            DateTime datet = DateTime.Now;
            Directory.CreateDirectory("Log");
            String filePath = "Log/"+datet.ToString("MM_dd") + ".log";
            
            if (!File.Exists(filePath))
            {
                FileStream files = File.Create(filePath);
                files.Close();
            }
            try
            {
                StreamWriter sw = File.AppendText(filePath);
                sw.WriteLine(datet.ToString("MM/dd hh:mm:ss") + "> " + message);
                sw.Flush();
                sw.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
    }
}
